#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Time    : 2021/3/16 21:41
# Author  : Keyman
# File    : prefix_average.py


def prefix_average1(s: list):
    """Return list such that, for all j, A[j] equals average of S[0], ..., S[j]."""
    n = len(s)
    a = [0] * n
    for j in range(n):
        total = 0
        for i in range(j + 1):
            total += s[j]
        a[j] = total / (j + 1)
    return a


def prefix_average2(s: list):
    """Return list such that, for all j, A[j] equals average of S[0], ..., S[j]."""
    n = len(s)
    a = [0] * n
    for j in range(n):
        a[j] = sum(s[0:j + 1] / j + 1)
    return a


def prefix_average3(s: list):
    """Return list such that, for all j, A[j] equals average of S[0], ..., S[j]."""
    n = len(s)
    a = [0] * n
    total = 0
    for j in range(n):
        total += s[j]
        a[j] = total / (j + 1)
    return a


if __name__ == '__main__':
    pass
